package com.peng.scalatest

object ScalaTest6_CaseClass {
  def main(args: Array[String]): Unit = {
    val car1 = new Car("xiaoming", 12)
    val car2 = new Car("xiaoming", 12)
    println(car1 == car2) //true

    val alice = new Car("Alice", 25)
    val bob = new Car("Bob", 32)
    val charlie = new Car("Charlie", 32)

    for (car <- List(alice, bob, charlie)) {
      car match {
        case Car("Alice", 25) => println("Hi Alice!")
        case Car("Bob", 32) => println("Hi Bob!")
        case Car(name, age) =>
          println("Age: " + age + " year, name: " + name + "?")
      }
    }
  }


}

// 属性值相同的对象 可以比较相同
case class Car(name: String, age: Int) {

}
